<template>
    <div>
    <el-row>
        <br>
        <!--<el-button>默认按钮</el-button>-->
        <el-button type="primary" @click="getTodayMoney">当日销售额</el-button>
        <el-button type="success" @click="getTodayVolume">当日销售量</el-button>
        <!--<el-button type="info">昨日销售额</el-button>-->
        <el-button type="warning" @click="getYestodayMoney">昨日销售额</el-button>
        <el-button type="danger" @click="getRecentSevenDaysMoney">近七日销售额</el-button>
    </el-row><br>
    <el-table
            :data="tableData"
            style="width: 100%">
        <el-table-column
                prop="date"
                label="日期"
                width="900">
        </el-table-column>
        <el-table-column
                prop="money"
                label="系统销售额/销售量">
        </el-table-column>
    </el-table>
    </div>
</template>

<script>
    export default {
        name: "FinanceSystem",
        data() {
            return {
                tableData: [
                //     {
                //     date: '2016-05-02',
                //     name: '王小虎',
                // }, {
                //     date: '2016-05-04',
                //     name: '王小虎',
                // }, {
                //     date: '2016-05-01',
                //     name: '王小虎',
                // }, {
                //     date: '2016-05-03',
                //     name: '王小虎',
                // }
                ]
            }
        },
        methods: {
            getTodayMoney(){
                var _vm = this
                this.tableData= []
                this.service.get('/finance/manage/finance/get_today_money').then(res=>{
                    console.log(res)
                    // res.data.data.list.forEach(function (item, index) {
                    var now=new Date().getFullYear() +  "-" +(new Date().getMonth() + 1).toString().padStart(2, "0") +  "-" + new Date().getDate().toString().padStart(2, "0")
                    console.log(now)
                        _vm.tableData= [
                            {
                                date:now,
                                money:res.data.data
                            }
                        ]
                    // })
                    // _vm.listLoading = false;
                })
            },
            getTodayVolume(){
                var _vm = this
                this.tableData= []
                this.service.get('/finance/manage/finance/get_today_volume').then(res=>{
                    console.log(res)
                    // res.data.data.list.forEach(function (item, index) {
                    var now=new Date().getFullYear() +  "-" +(new Date().getMonth() + 1).toString().padStart(2, "0") +  "-" + new Date().getDate().toString().padStart(2, "0")
                    console.log(now)
                    _vm.tableData= [
                        {
                            date:now,
                            money:res.data.data
                        }
                    ]
                })
            },
            getYestodayMoney() {
                var _vm = this
                this.tableData= []
                this.service.get('/finance/manage/finance/get_yesterday_money').then(res=>{
                    console.log(res)
                    var now=new Date().getFullYear() +  "-" +(new Date().getMonth() + 1).toString().padStart(2, "0") +  "-" +(new Date().getDate()-1).toString().padStart(2, "0")
                    console.log(now)
                    _vm.tableData= [
                        {
                            date:now,
                            money:res.data.data
                        }
                    ]
                })
            },
            getRecentSevenDaysMoney(){
                var _vm = this
                this.tableData= []
                this.service.get('/finance/manage/finance/get_recent_seven_days_money').then(res=>{
                console.log(res)
                    var nowtime=new Date()
                    var now=new Date(nowtime-6*24*3600*1000).getFullYear() +  "-" +(new Date(nowtime-6*24*3600*1000).getMonth() + 1).toString().padStart(2, "0") +  "-" + new Date(nowtime-6*24*3600*1000).getDate().toString().padStart(2, "0")+"  至  "+
                        new Date().getFullYear() +  "-" +(new Date().getMonth() + 1).toString().padStart(2, "0") +  "-" +new Date().getDate().toString().padStart(2, "0")
                    console.log(now)
                _vm.tableData= [
                    {
                        date:now,
                        money:res.data.data
                    }
                ]
            })
    },

        }
    }
</script>

<style scoped>
</style>